package info.sean.controller;


import info.sean.config.Userproperties;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {


       @Autowired
        Userproperties userproperties;



    @RequestMapping("/hello/springboot")
    @ResponseBody
    public String hellWorld() {
            System.out.println(userproperties);
        System.out.println("hellowrod");
        return "helloWorold";

    }
}



/**
 *      // 不加键这样会为null
 *         String username1 = environment.getProperty("username1");
 *         String name = environment.getProperty("name");
 *         String age = environment.getProperty("age");
 *         String girls = environment.getProperty("girls[1]");
 */

/**
 *  // 正确取值 这里也是user默认springboot访问
 *         String username1 = environment.getProperty("username1");
 *         String name = environment.getProperty("user1.name");
 *         String age = environment.getProperty("user1.age");
 *         String girls = environment.getProperty("user1.girls[1]");
 *
 *         System.out.println("usename1:" + username1);
 *         System.out.println("user1:" + name);
 *         System.out.println("age1:" + age);
 *         System.out.println("girls1:" + girls);
 *         System.out.println("hellowrod");
 *         return "helloWorold";
 */













/**
 * // 这里取值的时候要注意 springboot默认找的是系统username
 *
 *     @Value("${username1}")
 *     private String username1;
 *
 *     @Value("${user.name}")
 *     private String name;
 *
 *     @Value("${user.age}")
 *     private Integer age;
 *
 *     //这只是个集合这样取值  不是这这样取值会存在illA一异常
 *
 *     @Value("${user.girls[0]}")
 *     private String girls;
 *
 *
 *     @RequestMapping("/hello/springboot")
 *     @ResponseBody
 *     public String hellWorld() {
 *
 *         System.out.println("usename:" + username1);
 *         System.out.println("user:" + name);
 *         System.out.println("age:" + age);
 *         System.out.println("girls:" + girls);
 *         System.out.println("hellowrod");
 *         return "helloWorold";
 *     }
 */